package me.zhengjie.modules.management.rest.admin;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.management.domain.ConferenceType;
import me.zhengjie.modules.management.domain.MrConferencePurpose;
import me.zhengjie.modules.management.domain.Pageable;
import me.zhengjie.modules.management.service.ConferenceTypeService;
import me.zhengjie.modules.management.service.MrConferencePurposeService;
import me.zhengjie.modules.management.service.dto.ConferenceTypeQueryCriteria;
import me.zhengjie.modules.management.service.dto.MrConferencePurposeCriteria;
import me.zhengjie.utils.SecurityUtils;
import org.springframework.web.bind.annotation.*;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

/**
 * @Author: yuchao.wang
 * @Date: 2020/12/7
 * @Description: 预约教室类型
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "MR:预约教室类型")
@RequestMapping("/api/conferenceType")
public class ConferenceTypeController {

    private final ConferenceTypeService conferenceTypeService;

    @GetMapping
    @Log("获取所有会议室类型信息")
    @ApiOperation("获取所有会议室类型信息")
    public Object getAllList(ConferenceTypeQueryCriteria conferenceTypeQueryCriteria, Pageable pageable){
        return  conferenceTypeService.findByCriteria(conferenceTypeQueryCriteria,pageable);
    }

    @PostMapping
    @Log("新增会议室类型信息")
    @ApiOperation("新增会议室类型信息")
    public void addConferenceType(@RequestBody ConferenceType conferenceType){
        conferenceType.setCreateUserId(SecurityUtils.getCurrentUsername());
        conferenceType.setCreateDateTime(new Timestamp(new Date().getTime()));
        conferenceTypeService.create(conferenceType);
    }

    @PutMapping
    @Log("修改会议室类型信息")
    @ApiOperation("修改会议室类型信息")
    public void updateConferenceType(@RequestBody ConferenceType conferenceType){
        conferenceType.setModifyUserId(SecurityUtils.getCurrentUsername());
        conferenceType.setModifyDateTime(new Timestamp(new Date().getTime()));
        conferenceTypeService.update(conferenceType);
    }

    @DeleteMapping
    @Log("删除会议室类型信息")
    @ApiOperation("删除会议室类型信息")
    public void delConferenceRoomEquips(@RequestBody List<Integer> ids){
        conferenceTypeService.delete(ids);
    }

    @GetMapping(value = "/find")
    @Log("根据ID查询具体教室类型")
    @ApiOperation("根据ID查询具体教室类型")
    public Object getById(Integer typeId) {
        return conferenceTypeService.findById(typeId);
    }

}
